{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">昵称：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="nickname" value="" name="nickname" class="form-control" placeholder="请输入昵称">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">头像：</label>
						<div class="col-sm-6">
							<input type="text" autocomplete="off" id="avatar" value="" {if condition="config('my.img_show_status') eq true"}onmousemove="showBigPic(this.value)" onmouseout="closeimg()"{/if} name="avatar" class="form-control" placeholder="请输入头像">
							<span class="help-block m-b-none avatar_process"></span>
						</div>
						<div class="col-sm-2" style="position:relative; right:30px;">
							<span id="avatar_upload"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">余额：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="balance" value="" name="balance" class="form-control" placeholder="请输入余额">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">真实姓名：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="real_name" value="" name="real_name" class="form-control" placeholder="请输入真实姓名">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">手机号：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="phone" value="" name="phone" class="form-control" placeholder="请输入手机号">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">密码：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="pwd" value="" name="pwd" class="form-control" placeholder="请输入密码">
						</div>
					</div>
					<div class="form-group layui-form" style="display: none">
						<label class="col-sm-2 control-label">年龄：</label>
						<div class="col-sm-9">
							<div class="layui-input-inline" style="width: 160px;">
								<select id="age" name="age" class="province-selector">
									<option value="">选择年龄</option>
									{for start="20" end="81" }
									<option value="{$i}"  >{$i}岁</option>
									{/for}
								</select>
							</div>
						</div>
					</div>

					<div class="form-group"  style="display: none">
						<label class="col-sm-2 control-label">身高：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="height"  name="height" class="form-control" placeholder="请输入身高">
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">置顶卡：</label>
						<div class="col-sm-9">
							<input hidden="hidden" name="top_card_id" id="top_card_id" value=""/>
							<input name="top_card_name" readonly class="form-control" id="top_card_name"
								   value=""/>
							<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.chooseTop()">
								选择
							</button>
						</div>
					</div>

					<div class="form-group"  style="display: none">
						<label class="col-sm-2 control-label">生活照：</label>
						<div class="col-sm-6">
							<div class="images pic_list">
								<li id="images_upload"></li>
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none images_process"></span>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">标签(英文逗号,隔开)：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="tags" value="" name="tags" class="form-control" placeholder="请输入标签用英文逗号,隔开">
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">真实认证标签(英文逗号,隔开)：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="certify_tags" value="" name="certify_tags" class="form-control" placeholder="请输入真实认证标签用英文逗号,隔开">
						</div>
					</div>


					<div class="form-group">
						<label class="col-sm-2 control-label">推荐标签：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="recommend_tags" value="" name="recommend_tags" class="form-control" placeholder="请输入推荐标签用英文逗号,隔开">
						</div>
					</div>


					<!--lwx 是否认证-->
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否认证：</label>
						<div class="col-sm-9">
							<input name="is_auth" value="1" type="radio"   title="是" checked>
							<input name="is_auth" value="0" type="radio"   title="否">
						</div>
					</div>


					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否红娘：</label>
						<div class="col-sm-9">
							<input name="is_matchmaker" value="1" type="radio"   title="是" checked>
							<input name="is_matchmaker" value="0" type="radio"   title="否">
						</div>
					</div>

					<!-- 是否家长-->
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否家长：</label>
						<div class="col-sm-9">
							<input name="is_parent" value="1" type="radio"   title="是"  checked>
							<input name="is_parent" value="0" type="radio"   title="否">
						</div>
					</div>


					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否会员：</label>
						<div class="col-sm-9">
							<input name="is_vip" value="1" type="radio"   title="是"  checked>
							<input name="is_vip" value="0" type="radio"   title="否">
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">状态：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['status'])){ $info['status'] = 1; }; ?>
							<input name="status" value="1" type="radio" {if condition="$info.status eq '1'"}checked{/if} title="正常">
							<input name="status" value="0" type="radio" {if condition="$info.status eq '0'"}checked{/if} title="拉黑">
						</div>
					</div>


					<div class="form-group">
						<label class="col-sm-2 control-label">会员过期时间：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="expires_time" value="" name="expires_time" class="form-control" placeholder="请输入会员过期时间">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">父级ID：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="p_id" value="" name="p_id" class="form-control" placeholder="请输入父级id">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">上级红娘ID：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="matchmaker_id" value="" name="matchmaker_id" class="form-control" placeholder="请输入红娘id">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">邀请二维码：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="qr_code" value="" name="qr_code" class="form-control" placeholder="请输入邀请二维码">
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否是管理员：</label>
						<div class="col-sm-9">
							<input name="is_admin" value="1" type="radio"   title="是"  checked>
							<input name="is_admin" value="0" type="radio"   title="否">
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">红心余额：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="virtual_currency_balance" value="" name="virtual_currency_balance" class="form-control" placeholder="请输入红心余额">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">会员卡号：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="vip_number" value="" name="vip_number" class="form-control" placeholder="请输入会员卡号">
						</div>
					</div>
					<div class="form-group layui-form"  style="display: none">
						<label class="col-sm-2 control-label">性别：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['sex'])){ $info['sex'] = 1; }; ?>
							<input name="sex" value="1" type="radio" {if condition="$info.sex eq '1'"}checked{/if} title="男">
							<input name="sex" value="0" type="radio" {if condition="$info.sex eq '0'"}checked{/if} title="女">
						</div>
					</div>

					<div class="form-group"  style="display: none">
						<label class="col-sm-2 control-label">简介：</label>
						<div class="col-sm-9">
								<textarea id="s_desc" name="s_desc" class="form-control"
										  placeholder="请输入简介"></textarea>
						</div>
					</div>
				<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.add()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
layui.use(['form'],function(){});
uploader('avatar_upload','avatar','image',false,'','{:getUploadServerUrl()}');

uploader('images_upload', 'images', 'image', true, '{$info.pictures}', '{:getUploadServerUrl()}');
setUploadButton('images_upload');

laydate.render({elem: '#create_time',type: 'datetime',trigger:'click'});
laydate.render({elem: '#expires_time',type: 'datetime',trigger:'click'});
var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {
	 }
}

CodeInfoDlg.collectData = function () {
	this.set('uid').set('nickname').set('avatar').set('balance').set('real_name').set('phone')
			.set('is_auth').set('create_time').set('is_matchmaker').set('is_vip').set('expires_time')
			.set('p_id').set('qr_code').set('virtual_currency_balance').set('vip_number').set('s_desc').set('pwd')
			.set('top_card_id').set('top_card_name').set('tags').set('age').set('height').set('certify_tags').set('recommend_tags');
};

CodeInfoDlg.chooseTop = function () {
	var index = layer.open({
		type: 2,
		title: '置顶卡',
		area: ['800px', '100%'],
		fix: false,
		maxmin: true,
		content: Feng.ctxPath + '/ZhTopCard/selectList'
	});
	if (!IsPC()) {
		layer.full(index)
	}
}

function GetTopValue(value) {
	$('#top_card_name').val(value.name)
	$('#top_card_id').val(value.id)
	console.log('获取上级推荐人', value)
}

CodeInfoDlg.add = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }

	var images = [];
	$(".images li").each(function () {
		if ($(this).find('img').attr('src')) {
			images.push($(this).find('img').attr('src'));
		}
	});

	 var status = $("input[name = 'status']:checked").val();
	 var is_admin = $("input[name = 'is_admin']:checked").val();
	 var sex = $("input[name = 'sex']:checked").val();
	 var ajax = new $ax(Feng.ctxPath + "/Member/add", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	ajax.set('pictures', JSON.stringify(images));
	 ajax.set('status',status);
	 ajax.set('is_admin',is_admin);
	 ajax.set('sex',sex);
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
